@turf/isobands and @turf/isolines check pointGrid input is actually gridded already#2927
Merged
@turf/isobands and @turf/isolines check pointGrid input is actually gridded already#2927
Conversation
smallsaucepan
approved these changes
Aug 31, 2025
packages/turf-isobands/index.ts
Outdated
| * | ||
| * @function | ||
| * @param {FeatureCollection<Point>} pointGrid input points - must be square or rectangular | ||
| * @param {FeatureCollection<Point>} pointGrid input points - must be square or rectangular and already gridded |
Member
There was a problem hiding this comment.
Is there a clearer way to express this? Maybe cribbing from the comment where we actually do the check:
must be square or rectangular, and already gridded. That is, have consistent x and y dimensions, and be at least 2x2 in size.
|
|
||
| // Isoline methods | ||
| const matrix = gridToMatrix(pointGrid, { zProperty: zProperty, flip: true }); | ||
|
|
Member
There was a problem hiding this comment.
We do really need to find a way to share common code internally 😅
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
We were seeing some issues filed around these methods not working as expected. After looking at the data it appears that the pointGrid input is not always evenly spaced gridded points. When this happens
gridToMatrix()results in an unusable result. The matrix is either not large enough to ever make any cells for marchingsquares, or of inconsistent dimensions due to not reusing the same latitudes across points (even just a slight discrepancy in the values will cause an issue).This adds explicit checks for this condition, and slightly clarifies the docs on what we're expecting to be passed in. I'm open to improvements in the wording here for clarity.
Fixes #2509, #2081